from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')

browser = webdriver.Chrome(chrome_options=chrome_options)
try:
    url_str = 'https://www.zhihu.com/people/wu-hui-19/following'
    browser.get(url_str)
    element = browser.find_element_by_css_selector('.ProfileHeader-expandButton')
    element.click()
    sex = browser.find_element_by_xpath("//meta[@itemprop='gender']")
    print(sex.get_attribute('content'))
    agrees = browser.find_element_by_xpath("//meta[@itemprop='zhihu:voteupCount']")
    print(agrees.get_attribute('content'))
    thanks = browser.find_element_by_xpath("//meta[@itemprop='zhihu:thankedCount']")
    print(thanks.get_attribute('content'))
    answers = browser.find_element_by_xpath("//meta[@itemprop='zhihu:answerCount']")
    print(answers.get_attribute('content'))
    posts = browser.find_element_by_xpath("//meta[@itemprop='zhihu:articlesCount']")
    print(posts.get_attribute('content'))
    followers = browser.find_element_by_xpath("//meta[@itemprop='zhihu:followerCount']")
    print(followers.get_attribute('content'))
    
    items = browser.find_elements_by_css_selector('.ProfileHeader-detailItem')
    for item in items:
        print(item.find_element_by_css_selector('.ProfileHeader-detailLabel').text)
        print(item.find_element_by_css_selector('.ProfileHeader-detailValue').text)
finally:
    browser.close()
